/**
 * Created by apple on 2017/7/23.
 */
import {createStore} from 'redux';
export default function () {
  //第一步 定义计算规则
  function counter(state = 0, action) {
    switch (action.type){
      case 'INCREMENT':
        return state + 1;
      case 'DECREMENT':
        return state - 1;
      default:
        return state;
    }
  }
  //第二步:根据计算规则生成store
  let store = createStore(counter);
  // 第三步:定义数据变化之后的派发规则
  store.subscribe(()=>{
    console.log(store.getState()+"规则变了1")
  });
  store.subscribe(()=>{
    console.log(store.getState()+"规则变了2")
  });
  //第四步:触发
  store.dispatch({type:'INCREMENT'})

}





